perm filename MAPTST.PAL[AL,HE] blob
sn#290088 filedate 1977-06-28 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00009 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 This is a test program to try out some ideas about the
C00004 00003 Map definitions
C00006 00004 Common area
C00008 00005 COMMON, PINIT, TOSPC
C00013 00006 SWITCH
C00016 00007 DRIVER
C00017 00008 Area zero
C00019 00009 .END
C00020 ENDMK
C⊗;
COMMENT ⊗ This is a test program to try out some ideas about the
proper use of the glorious Panofsky map. We will set up four maps,
each of which shares locations 0 → 17777 and 120000 → 177777. The
locations 20000 → 30000 will be distinct for each of the four maps.
Into each of these areas will be assembled a printing routine (which
will identify which county it is in) and a call to each of the other
county's map routines. Calling an unreachable location will be done
by this code:
MOV #LNAME,-(SP) ;The link name of the routine
JSR PC,SWITCH ;A routine in common space to do it all
The link name is an pointer into the link table. Each entry in that
table is two words. The second is the number of the appropriate
county (0:3), and the first is the address in that county's scheme.
The switch routine will keep track of the stack and will set the
return address to something in itself. It will therefore also have
to fix up the return. ⊗
; Map definitions
;Page tables
PTAB0 = 166000 ;100 words, 1 per page
PTAB1 = 166200 ;100 words, 1 per page
PTAB2 = 166400 ;100 words, 1 per page
PTAB3 = 166600 ;100 words, 1 per page
;Page table entries (each one for 2000 bytes)
WRINTO == 100000 ;Page has been written into
ACCESD == 40000 ;Page has been accessed
WRPERM == 20000 ;Page may be written into
RDPERM == 10000 ;Page may be read from
UNIBIT == 4000 ;on => unibus only. off => fastbus only
PHSPAG == 3777 ;high order address bits of physical page
;Map space table
KISPCE = 167030 ;Kernel I space
KDSPCE = 167020 ;Kernel D space
SISPCE = 167032 ;Supervisor I space
SDSPCE = 167022 ;Supervisor D space
NISPCE = 167034 ;Unused I space
NDSPCE = 167024 ;Unused D space
UISPCE = 167036 ;User I space
UDSPCE = 167026 ;User D space
;Map space table entries
PTABNO == 1400 ;The page table (0:3) to use for this space
TRANSP == 200 ;1 => no mapping
MXVRPG == 176 ;Maximum page that may be referenced
;Status registers
STATR0 = 167000 ;Status register 0
MAPENB == 100000 ;1 => enable mapping
; Common area
.INSRT ALHED[AL,HE]
.INSRT K2DEF.PAL[11,SYS]
.INSRT ALIO.PAL[AL,HE]
MAINBL: PDBLK 100,S ;Makes a process descriptor for main process
PUTLOC JOBDAT, MAINBL
PUTLOC JOBSA, DRIVER
LTAB: .BLKW 40 ;Enough for 20 links
LHI0: HI0
0
LHI1: HI1
1
LHI2: HI2
2
LHI3: HI3
3
COMMENT ⊗
If you want to define where, say, FOO is, you should do this:
PUTLOC LFOO, FOO ;The address
PUTLOC LFOO+2, 2 ;Assuming that you are in county 2
If you want to call, say, FOO, you should do this:
MOV #LFOO,-(SP) ;This will get cleared off.
JSR PC,SWITCH ;Will even do the return properly
⊗
; COMMON, PINIT, TOSPC
COMMON:
Comment ⊗ Takes the page table start address in R0 (PTAB0:PTAB3).
Sets virtual memory 0-17777 and 120000-177777 to the equivalent
physical memory. ⊗
MOV R2,-(SP) ;Save R2
MOV #UNIBIT+WRPERM+RDPERM,R1 ;Page table entry
MOV #10,R2 ;Number of entries for low common page table
COM1: MOV R1,(R0)+ ;Put in the entry
INC R1 ;Set for next physical page
SOB R2,COM1 ;Repeat
;R0 is now set to word 10, R1 to physical page 10.
ADD #100,R0 ;R0 set to word 50 (virt. add. 120000)
ADD #40,R1 ;R1 set to page 50 (phys. add. 120000)
MOV #20,R2 ;Number of entries for mid common page table
COM2: MOV R1,(R0)+ ;Put in the entry
INC R1 ;Set for next physical page
SOB R2,COM2 ;Repeat
MOV #UNIBIT+WRPERM+RDPERM+370,R1 ;page 370 (phys. add. 760000)
MOV #10,R2 ;Number of entries for high common page table
COM3: MOV R1,(R0)+ ;Put in the entry
INC R1 ;Set for next physical page
SOB R2,COM3 ;Repeat
MOV (SP)+,R2 ;Restore R2
RTS PC ;Done
PINIT:
CLR STATR0 ;Turn off mapping for the nonce
MOV #SWSTCK,PTR ;Initialize the special stack
; Set up the four page tables
MOV #PTAB0,R0 ;Clear all page table entries to start with
MOV #400,R1 ;
PINI0: CLR (R0)+ ;
SOB R1,PINI0 ;
;Page table 0
MOV #PTAB0,R0 ;
JSR PC,COMMON ;
MOV #UNIBIT+WRPERM+RDPERM+10,R1 ;Page table entry
MOV #4,R2 ;Number of entries for the distinct page table
MOV #PTAB0+20,R0;Page table entry
PINI1: MOV R1,(R0)+ ;Put in the entry
INC R1 ;Set for next physical page
SOB R2,PINI1 ;Repeat
;Page table 1
MOV #PTAB1,R0 ;
JSR PC,COMMON ;
MOV #UNIBIT+WRPERM+RDPERM+14,R1 ;Page table entry
MOV #4,R2 ;Number of entries for the distinct page table
MOV #PTAB1+20,R0;Page table entry
PINI2: MOV R1,(R0)+ ;Put in the entry
INC R1 ;Set for next physical page
SOB R2,PINI2 ;Repeat
;Page table 2
MOV #PTAB2,R0 ;
JSR PC,COMMON ;
MOV #UNIBIT+WRPERM+RDPERM+20,R1 ;Page table entry
MOV #4,R2 ;Number of entries for the distinct page table
MOV #PTAB2+20,R0;Page table entry
PINI3: MOV R1,(R0)+ ;Put in the entry
INC R1 ;Set for next physical page
SOB R2,PINI3 ;Repeat
;Page table 3
MOV #PTAB3,R0 ;
JSR PC,COMMON ;
MOV #UNIBIT+WRPERM+RDPERM+24,R1 ;Page table entry
MOV #4,R2 ;Number of entries for the distinct page table
MOV #PTAB3+20,R0;Page table entry
PINI4: MOV R1,(R0)+ ;Put in the entry
INC R1 ;Set for next physical page
SOB R2,PINI4 ;Repeat
;turn it all on, hope it works.
PINI5: CLR R0 ;Set all to map 0
JSR PC,TOSPC ;
MOV #MAPENB,STATR0 ;Turns it on.
RTS PC ;Done
TOSPC: Comment ⊗ R0 has 0, 1, 2, 3. We want to move the user
to that space. Change both the I and D spaces. ⊗
ASH #10,R0 ;
ADD #176,R0 ;Maximum accessible page
MOV R0,KISPCE ;Set the instruction space
MOV R0,KDSPCE ;Set the data space
MOV R0,SISPCE ;Set the instruction space
MOV R0,SDSPCE ;Set the data space
MOV R0,NISPCE ;Set the instruction space
MOV R0,NDSPCE ;Set the data space
MOV R0,UISPCE ;Set the instruction space
MOV R0,UDSPCE ;Set the data space
RTS PC ;Done
; SWITCH
COMMENT ∞ THIS IS THE OLD VERSION
SWITCH:
COMMENT ⊗ The stack holds a pointer into the LTAB. ⊗
MOV R0,-(SP) ;Save R0
MOV R1,-(SP) ;Save R1
MOV PTR,R1 ;The stack for this routine
MOV 4(SP),-(R1) ;Save the return address
MOV UISPCE,-(R1) ;Where we are coming from
MOV 6(SP),-(R1) ;Save the pointer into the LTAB
MOV (R1),R0 ;R0 ← pointer into LTAB
MOV 2(R0),R0 ;R0 ← desired county
JSR PC,TOSPC ;Now we have the right county.
MOV (R1)+,R0 ;R0 ← pointer into LTAB
MOV R1,PTR ;
MOV (R0),TEMP ;Stack the address to jump to
MOV (SP)+,R1 ;Restore R1
MOV (SP)+,R0 ;Restore R0
TST (SP)+ ;Get rid of old return address
TST (SP)+ ;Get rid of the pointer to LTAB
JSR PC,@TEMP ;Jump to the routine, return here
MOV @PTR,UISPCE ;Go back to old space
MOV @PTR,UDSPCE
MOV @PTR,SISPCE
MOV @PTR,SDSPCE
MOV @PTR,KISPCE
MOV @PTR,KDSPCE
ADD #2,PTR ;
MOV @PTR,-(SP) ;The return address
ADD #2,PTR ;
RTS PC ;Return
;∞ END OF OLD VERSION
TEMP: .BLKW 1 ;Variable in SWITCH
PTR: .BLKW 1 ;Variable in SWITCH
.BLKW 100 ;Stack used in SWITCH
SWSTCK: .BLKW 1 ;Top of stack
SWITCH:
MOV R0,-(SP) ;Save R0
MOV 4(SP),R0 ;R0 ← pointer into LTAB
BOUNCE 2(R0),(R0)
MOV (SP)+,R0 ;Restore R0
MOV (SP)+,(SP) ;clear argument to SWITCH
RTS PC
; DRIVER
DRIVER:
JSR PC,PINIT ;
MOV #LHI0,-(SP) ;
JSR PC,SWITCH ;
DISMIS ;
PATCH: .BLKW 100 ;Patch area
; Area zero
.MACRO PLACE PHYS,VIRT
.OFFSET 0
.=PHYS
.OFFSET VIRT-PHYS
.ENDM
HI0:
MOV #MESI0,R0 ;Say hello
JSR PC,TYPSTR ;
MOV #LHI1,-(SP);
JSR PC,SWITCH ;
MOV #MESF0,R0 ;Say goodbye
JSR PC,TYPSTR ;
RTS PC ;Done
MESI0: ASCIE </
INTO AREA ZERO/>
MESF0: ASCIE </
OUT OF AREA ZERO/>
PLACE 30000,20000
HI1:
MOV #MESI1,R0 ;Say hello
JSR PC,TYPSTR ;
MOV #LHI2,-(SP);
JSR PC,SWITCH ;
MOV #MESF1,R0 ;Say goodbye
JSR PC,TYPSTR ;
RTS PC ;Done
MESI1: ASCIE </
INTO AREA ONE/>
MESF1: ASCIE </
OUT OF AREA ONE/>
PLACE 40000,20000
HI2:
MOV #MESI2,R0 ;Say hello
JSR PC,TYPSTR ;
MOV #LHI3,-(SP);
JSR PC,SWITCH ;
MOV #MESF2,R0 ;Say goodbye
JSR PC,TYPSTR ;
RTS PC ;Done
MESI2: ASCIE </
INTO AREA TWO/>
MESF2: ASCIE </
OUT OF AREA TWO/>
PLACE 50000,20000
HI3:
MOV #MESI3,R0 ;Say hello
JSR PC,TYPSTR ;
MOV #MESF3,R0 ;Say goodbye
JSR PC,TYPSTR ;
RTS PC ;Done
MESI3: ASCIE </
INTO AREA THREE/>
MESF3: ASCIE </
OUT OF AREA THREE/>
PUTLOC LHI3, HI3 ;The address
PUTLOC LHI3+2, 3 ;County
.END